<template>
  <ul class="song-list">
    <li class="song-item" v-for="(song, index) in item" :key="song.id" @click="playme(song)">
      <em v-show="shownumber" :class="{ active:index<3 }">
        {{(index &lt; 9)?"0"+(index+1):(index+1)}}
      </em>
      <em v-show="playnumber">{{(index+1)}}</em>
      <div class="line">
        <div class="item">
          <div class="item-details thide">
            <i v-html="$options.filters.title(song.name,keywords)"></i>
            <i class="album" v-show="song.song.alias != 0">({{ song.song.alias[0] }})</i>
          </div>
          <div class="item-info thide">
            <i v-if="song.song.privilege.maxbr > 320000" class="sq"></i>
            <span>
                <span v-html="$options.filters.title(song.song.artists[0].name,keywords)"></span> -
                <span v-html="$options.filters.title(song.name,keywords)"></span>
            </span>
          </div>
        </div>
        <div class="item-img" >
          <span></span>
        </div>
      </div>
    </li>
  </ul>
</template>
<script>
export default {
  props: {
    item: Array,
    keywords:{
      type:String,
      default:"",
    },
    shownumber: {
      type: Boolean,
      default: false,
    },
    playnumber: {
      type: Boolean,
      default: false,
    },
  },
  methods:{
    playme(song) {
				this.$emit("play", song)
		}
  },
  filters:{
    title(value,keywords){
      let reg=new RegExp(keywords,'gi');
      return value.replace(reg,`<span style="color:skyblue;">${keywords}</span>`);
    }
    }
};
</script>

<style lang="less" scoped>
.song-list {
  flex-direction: column;
  .song-item {
    display: flex;
    padding-left: 10px;
    position: relative;
    & > em {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 40px;
      font-size: 17px;
      color: #999;
      margin-left: -10px;
      &.active {
        color: red;
      }
    }
    .line {
      display: flex;
      position: relative;
      flex: 1 1 auto;

      .item {
        display: flex;
        flex-direction: column;
        padding: 6px 0px;
        flex: 1 1 auto;
        width: 0px;

        .item-details {
          .album {
            color: #888;
            margin-left: 4px;
          }

          & > i {
            font-size: 17px;
            & /deep/ span{
              font-size: 17px;
            }
          }
        }
        .item-info {
          .sq {
            display: inline-block;
            width: 12px;
            height: 8px;
            margin-right: 4px;
            background: url("../assets/index_icon_2x.png") no-repeat 0 0;
            background-size: 166px 97px;
          }
          & > span {
            font-size: 12px;
            color: #888;
          }
        }
        & > span {
          font-size: 12px;
          color: #888;
          display: block;
        }
      }
      .item-img {
        display: flex;
        align-items: center;
        padding: 0 10px;
        & > span {
          display: inline-block;
          width: 22px;
          height: 22px;
          background: url("../assets/index_icon_2x.png") no-repeat -24px 0;
          background-size: 166px 97px;
        }
      }
      &::after {
        position: absolute;
        content: "";
        border: 0 solid rgba(0, 0, 0, 0.1);
        bottom: 0;
        left: 0;
        box-sizing: border-box;
        width: 100%;
        border-bottom-width: 1px;
      }
    }
  }
  .thide {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
  }
}
</style>